<template>
    <div>
        <h2>登录</h2>
        <table class="table table-bordered" border="1">
            <tr>
                <td align="right">用户名:</td>
                <td>
                    <input type="text" v-model="info.userName">
                </td>
            </tr>
            <tr>
                <td align="right">密码:</td>
                <td>
                    <input type="password" v-model="info.Pwd">
                </td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <input type="button" value="登录" class="btn btn-success" @click="login">
                </td>
            </tr>
        </table>
    </div>
</template>

<script setup lang="ts">

import axios from 'axios';
import { ref, reactive, onMounted } from 'vue';
import moment from 'moment';
import { useRoute, useRouter } from 'vue-router';
let route = useRoute();
let router = useRouter();

///////////////////////////////////////////////////////////////////////////////////////
let info = reactive({
    userName: '',
    Pwd: ''
});

/////////////////////////////////函数/////////////////////////////////////////////////////

//登录
const login = () => {
    if(info.userName==''){
alert('用户名不能为空');
return;
    }
    if(info.Pwd==''){
alert('密码不能为空');
return;
    }
    axios({
        url: 'https://localhost:7080/api/RoomType/Login',
        params: info,
        method: 'get'
    })
        .then(res => {
            if (res.data > 0) {
                alert('登录成功');
                router.push('addRoomType')
            } else {
                alert('密码有误，请重新输入');
            }
        })
}






</script>

<style scoped></style>